feat(rag): per-candidate saturation-tail primaries on the text fast path (ADDENDUM 4 Phase C)#1004
Conversation
…ath (ADDENDUM 4 Phase C) Candidates whose text_rank saturates the min(text_rank, 1) clamp collapsed to byte-identical imputed primaries, so unrelated documents matching the same terms tied exactly and release order fell to arbitrary chunk-id (live: canary #53/#54 identical rr@10 on the four fast-path headroom cases). - saturationTailUnit maps the rank's excess above the knee into [0,1) — pure, strictly monotone, set-independent - table facts (S2): similarity carries a 0.02-max tail into its dead (0.92, 0.94) cap band; hybridScore stays byte-identical, so selection scores, every gate/threshold, and the second-stage trigger are provably unchanged — similarity is exactly the release-order tie-break key - lexical chunks (S1): signature-guarded hybrid lift into the dead (0.48, 0.5) band; the sub-0.5 truthful-score contract holds - sub-knee imputation byte-identical (helper-derived test fixtures prove it: text_rank 0.45 still yields exactly 0.755/0.795) - discriminating test verified RED on the old formulas (id-order seats the distractor first) and green with the tail; tie-conservation guard proves genuinely equal text_ranks still fall to the coverage comparator (#987) - scope: resolves ties where the second stage does not engage (patient-safety, opioid, flowchart class); S3 document-lookup + S4 memory-card respreads are deferred as C-PR-2 candidates, evidence-gated on the post-merge canary Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughPhase C adds saturated-tail score imputation for table-fact and lexical-chunk retrieval, updates ordering regression tests, and documents the revised scoring contracts and review outcomes. ChangesSaturated retrieval scoring
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…etrieval review (#1004) (#1005) * Revert "feat(rag): per-candidate saturation-tail primaries on the text fast path (ADDENDUM 4 Phase C) (#1004)" This reverts commit f96217c. * docs(ledger): retain history rows + record the pending-review revert Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9 --------- Co-authored-by: Claude <noreply@anthropic.com>
Summary
Phase C (user-authorized after the Phase B null result): candidates whose
text_ranksaturates themin(text_rank, 1)clamp collapse to byte-identical imputed primaries, so unrelated documents matching the same terms tie exactly and release order falls to arbitrary chunk-id — the live mechanism behind the four fast-path headroom cases (canary #53/#54: identical rr@10 0.20/0.25/0.33/0.33).The fix, per the dedicated design investigation (full consumer map + envelope proof in the design record):
saturationTailUnit(tr)= (tr−1)/(tr−1+0.5) — pure, strictly monotone, set-independent (one candidate's value never depends on the rest of the pool).similaritycarries a ≤0.02 tail into its dead (0.92, 0.94) cap band;hybridScorestays byte-identical — so selection scores, every gate/threshold (all ≤0.82), and the second-stage trigger are provably unchanged.similarityis exactly the tie-break key after hybrid/releaseRankScore in the release comparators, so only exact-tie resolution changes.similarity === 0 && lexical_score && text_rank > 1); the sub-0.5 truthful-score contract holds (comment updated at thebuildRetrievalDiagnosticsgate; RC9 fabrication inventory amended).text_rank0.45 still yields exactly the historical 0.755/0.795 pair, keeping every pre-Phase-C guard's premise intact.Rejected designs (recorded for review): per-query min-max normalization (set-dependent; full-envelope spread gives raw ts_rank enough authority to reproduce the #118 recall-regression mechanism), rank-position tiers (ill-defined across interleaved variant streams; set-dependent), full-range log rescale (moves sub-knee values across the 0.62–0.82 gate ladder — direct recall risk).
Scope honesty: the tail resolves ties where the second-stage rerank does not engage — matching the live evidence (patient-safety, opioid, flowchart pools; the engaged ciwa-threshold pool sorts by position-derived releaseRankScore first). S3 (document-lookup respread) and S4 (memory-card confidence ties) are deferred as C-PR-2 candidates, evidence-gated on the post-merge canary.
Verification
rag-fast-path-ordering(11/11 — 6 new Phase C tests),retrieval-selection,rag-routing,rag-answer-fallback,ranking-tuning,rag-second-stage-rankingtext_ranks still produce identical primaries and fall to the coverage comparator (fix(rag): break saturated selection ties by query-term coverage, not rank score #987 contract preserved)npm run test— 3025 passed / 1 failed: the known container-onlypdf-extraction-budgetartifact (baselined on clean main)npm run lint+npm run typecheck+ prettier — cleannpm run eval:retrieval:quality(36/36 required) — cannot run locally (live keys are Actions-only). Live validation = one post-merge eval-canary dispatch (~$1–2, user-authorized cap) against the banked Enhance clinical safety and governance #54 baseline: doc/content recall must stay 1.0, zero per-case rr regressions; success signal = rr lift on the non-engaged headroom cases. I will dispatch it immediately on merge and report the pair.Risk and rollout
topScoresClosetrigger adjacency (a 0.03–0.04 hybrid gap crossing 0.04) — low frequency, caught by the second-stage suites + the canary; fallback is halving the S1 tail or deferring S1 to C-PR-2, both one-liners.RAG_RANKING_CONFIGuntouched, cache entries age out at TTL).Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy) — no schema/SQL change (the SQL clamp stays; the spread is app-side)Notes
7572c7f).🤖 Generated with Claude Code
https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Generated by Claude Code
Summary by CodeRabbit